/**
 * Copyright 2011 Adrian Witas
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.abstractmeta.code.g.core.code.builder;


import org.abstractmeta.code.g.code.JavaConstructor;
import org.abstractmeta.code.g.core.code.JavaConstructorImpl;

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;


/**
 * Provide generateBuilder implementation of org.abstractmeta.toolbox.code.JavaConstructor
 * This class has been auto-generated by code-g.
 */
public class JavaConstructorBuilder {



    private List<String> parameterModifiers = new ArrayList<String>();

    private List<Type> parameterTypes = new ArrayList<Type>();

    private List<String> parameterNames = new ArrayList<String>();

    private List<String> body = new ArrayList<String>();

    private List<String> modifiers = new ArrayList<String>();

    private String name;

    private List<Annotation> annotations = new ArrayList<Annotation>();

    private List<String> documentation = new ArrayList<String>();

    public List<Type> getParameterTypes() {
        return this.parameterTypes;
    }

    public JavaConstructorBuilder setParameterTypes(List<Type> parameterTypes) {
        this.parameterTypes = parameterTypes;
        return this;
    }

    public JavaConstructorBuilder addArgumentTypes(Collection<Type> argumentTypes) {
        this.parameterTypes.addAll(argumentTypes);
        return this;
    }



    public JavaConstructorBuilder addParameter(boolean finalModifier, String name, Type type) {
        return addParameter(finalModifier ? "final" : "", name, type);
    }

    public JavaConstructorBuilder addParameter(String name, Type type) {
        return addParameter("", name, type);
    }

    public JavaConstructorBuilder addParameter(String modifier, String name, Type type) {
        this.parameterModifiers.add(modifier);
        this.parameterNames.add(name);
        this.parameterTypes.add(type);
        return this;
    }

    


    public JavaConstructorBuilder addArgumentNames(Collection<String> argumentNames) {
        this.parameterNames.addAll(argumentNames);
        return this;
    }

    public List<String> getBody() {
        return this.body;
    }

    public JavaConstructorBuilder setBody(List<String> body) {
        this.body = body;
        return this;
    }

    public JavaConstructorBuilder addBody(String body) {
        this.body.add(body);
        return this;
    }

    public JavaConstructorBuilder addBody(Collection<String> body) {
        this.body.addAll(body);
        return this;
    }

    public List<String> getModifiers() {
        return this.modifiers;
    }

    public JavaConstructorBuilder setModifiers(List<String> modifiers) {
        this.modifiers = modifiers;
        return this;
    }

    public JavaConstructorBuilder addModifier(String modifier) {
        this.modifiers.add(modifier);
        return this;
    }


    public JavaConstructorBuilder addParameterModifiers(Collection<String> parameterModifiers) {
        this.parameterModifiers.addAll(parameterModifiers);
        return this;
    }

    public JavaConstructorBuilder addModifiers(Collection<String> modifiers) {
        this.modifiers.addAll(modifiers);
        return this;
    }

    public String getName() {
        return this.name;
    }

    public JavaConstructorBuilder setName(String name) {
        this.name = name;
        return this;
    }

    public List<Annotation> getAnnotations() {
        return this.annotations;
    }

    public JavaConstructorBuilder setAnnotations(List<Annotation> annotations) {
        this.annotations = annotations;
        return this;
    }

    public JavaConstructorBuilder addAnnotation(Annotation annotation) {
        this.annotations.add(annotation);
        return this;
    }

    public JavaConstructorBuilder addAnnotations(Collection<Annotation> annotations) {
        this.annotations.addAll(annotations);
        return this;
    }

    public List<String> getDocumentation() {
        return this.documentation;
    }

    public JavaConstructorBuilder setDocumentation(List<String> documentation) {
        this.documentation = documentation;
        return this;
    }

    public JavaConstructorBuilder addDocumentation(String documentation) {
        this.documentation.add(documentation);
        return this;
    }

    public JavaConstructorBuilder addDocumentation(Collection<String> documentation) {
        this.documentation.addAll(documentation);
        return this;
    }

    public JavaConstructor build() {
        JavaConstructor result = new JavaConstructorImpl(parameterModifiers, parameterTypes, parameterNames, body, modifiers, name, annotations, documentation);
        return result;
    }

    public void merge(JavaConstructor instance) {
        if (instance.getParameterModifiers() != null) {
            addParameterModifiers(instance.getParameterModifiers());
        }
        if (instance.getParameterTypes() != null) {
            addArgumentTypes(instance.getParameterTypes());
        }
        if (instance.getParameterNames() != null) {
            addArgumentNames(instance.getParameterNames());
        }
        if (instance.getBody() != null) {
            addBody(instance.getBody());
        }
        if (instance.getModifiers() != null) {
            addModifiers(instance.getModifiers());
        }
        if (instance.getName() != null) {
            setName(instance.getName());
        }
        if (instance.getAnnotations() != null) {
            addAnnotations(instance.getAnnotations());
        }
        if (instance.getDocumentation() != null) {
            addDocumentation(instance.getDocumentation());
        }

    }

}